import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'

import {HIDE_TABBAR_MUTATION,SHOW_TABBAR_MUTATION} from '@/type'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
	  //自定义的共享状态
	  isTabbarShow: true,
	  comingList:[]
  },
  getters:{
	  comingListGetter(state){
		  return state.comingList.filter((item,index)=>index<3)	//只取出前三个数据
	  }
  },
	  
  
  mutations: {	//唯一修改状态的位置
	  // HideMaizuoTabbar(state,data){
	  [HIDE_TABBAR_MUTATION] (state,data){
		  // console.log("HideMaizuoTabbar");
		  state.isTabbarShow = data;
	  },
	  // ShowMaizuoTabbar(state,data){
	  [SHOW_TABBAR_MUTATION] (state,data){
		  state.isTabbarShow = data;
	  },
	  comingListMutation(state,data){
		  //将数据放入vuex中可以起缓存作用
		  state.comingList = data;
	  }
		  
  },
  actions: {
	  //异步处理
	  getComingListAction(store){
		  axios({
			  url: "http://127.0.0.1:8003/comingshow/",
		  })
		  .then(res=>{
			  // console.log(res.data);
			  store.commit("comingListMutation",res.data);
		  })
	  }
  },
  modules: {
  }
})


var name = "key"
var obj = {
	[name]:"aaaa"		//把对象中的属性当作变量来处理
}

console.log(obj);